/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package game.module.Exploration;
import com.badlogic.gdx.physics.box2d.Body;
import org.anddev.andengine.entity.sprite.Sprite;
import org.anddev.andengine.opengl.texture.region.TextureRegion;
/**
 *
 * @author cow
 */
public class CharacterRepresentation {
	//varblok---------------------
	private static final float jumpSpeed = 10;
	private static final float horzSpeed = 10;
	private Sprite imageRep;
	private Body physicsRep;
	//============================


	public CharacterRepresentation(TextureRegion image){
		imageRep = new Sprite(100, 150, image);
		
	}

	public void setBody(Body bd){
		physicsRep = bd;
		physicsRep.setAngularDamping(1);
	}

	public boolean canJump(){
		return physicsRep.getLinearVelocity().y == 0;
	}

	/**
	 * jumps at vert percent of the maximum
	 * vertical speed. in all liklihood, vert will
	 * always be one.
	 * @param vert percentage of vertical speed
	 */
	public void jump(float vert){
		if(canJump()){
			physicsRep.setLinearVelocity(
				physicsRep.getLinearVelocity().x,
				jumpSpeed * vert
			);
		}
	}


	/**
	 * sets the horizontal speed as a percentage
	 * of the maximum speed
	 * @param horiz the percentage of the max horizontal speed
	 */
	public void transverse(float horiz){
			physicsRep.setLinearVelocity(
				horzSpeed * horiz,
				physicsRep.getLinearVelocity().y
			);
	}

	public void place(int x, int y){
		imageRep.setPosition(x, y);
	}

	public Sprite getRep(){
		return imageRep;
	}
/*
	public int getX(){
		//if(physicsReps != null)
	}
	public int getY(){
		return physicsRep == null ? (int)physicsRep.getPosition().y : 0;
	}*/
}
